Skip to content

Remove upper option from CholeskyCorrTransform - #8653

Merged
ricardoV94 merged 2 commits into
pymc-devs:mainfrom
saifmodan2006:fix/cholesky-corr-upper-8555
Nov 20, 2026
Merged

ricardoV94 merged 2 commits into
pymc-devs:mainfrom
saifmodan2006:fix/cholesky-corr-upper-8555

Conversation

@saifmodan2006

@saifmodan2006 saifmodan2006 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Description

Per @ricardoV94's review, the upper option is removed instead of fixed: nobody asked for it, and CholeskyCorrTransform's only internal use, in LKJCorr, always uses the lower-triangular factor. CholeskyCorrTransform now takes only n and always returns a lower-triangular factor.

Changes:

  • Removed the upper parameter and all upper branches from forward, backward, log_jac_det, _fill_triangular_spiral and _inverse_fill_triangular_spiral in pymc/distributions/transforms.py.
  • pymc/distributions/multivariate.py now calls CholeskyCorrTransform(n=n).
  • Tests drop the upper parametrization.

Prepared with AI assistance (Muse).

Related Issue

Checklist

  • Checked that the pre-commit linting/style checks pass
  • Included tests that prove the fix is effective or that the new feature works
  • Added necessary documentation (docstrings and/or example notebooks)
  • If you are a pro: each commit corresponds to a relevant logical change

No new documentation was needed: the transform docstring no longer mentions upper.

Type of change

  • New feature / enhancement
  • Bug fix
  • Documentation
  • Maintenance
  • Other (please specify):

Tests run

  • python -m pytest tests/distributions/test_transform.py: 76 passed, with 1 pre-existing failure in test_invalid_jacobian_broadcast_raises that fails the same way on unmodified main and passes in isolation.
  • python -m pytest tests/distributions/test_multivariate.py -k lkjcorr: 18 passed.
  • ruff format --check passes on all three files.

…r factor

backward() padded the filled block for the lower case only, so upper=True returned a lower-triangular factor with the correlations in the strictly lower part. forward() sliced the wrong sub-block for the upper case, and log_jac_det used the lower-case row weights. All three now depend on upper, and the upper-case tests cover forward, backward, round-trip, log_jac_det against autodiff, and valid correlation factors.

Fixes pymc-devs#8555
@welcome

welcome Bot commented Nov 19, 2026

Copy link
Copy Markdown

Thank You Banner]
💖 Thanks for opening this pull request! 💖 The PyMC community really appreciates your time and effort to contribute to the project. Please make sure you have read our Contributing Guidelines and filled in our pull request template to the best of your ability.

@read-the-docs-community

read-the-docs-community Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

Documentation build overview

📚 pymc | 🛠️ Build #36034500 | 📁 Comparing d335d8a against latest (bc3904b)

  🔍 Preview build  

3 files changed
± glossary.html
± _modules/pymc/distributions/multivariate.html
± _modules/pymc/distributions/transforms.html

@github-actions github-actions Bot added the bug label Nov 19, 2026
@ricardoV94

Copy link
Copy Markdown
Member

Just remove the option, nobody has asked for it

@saifmodan2006

Copy link
Copy Markdown
Contributor Author

Updated per @ricardoV94's review: the upper option is removed instead of fixed. CholeskyCorrTransform now takes only n and always returns a lower-triangular factor, matching its only internal use in LKJCorr. Changes: removed the upper parameter and all upper branches from forward, backward, log_jac_det, _fill_triangular_spiral and _inverse_fill_triangular_spiral in pymc/distributions/transforms.py; pymc/distributions/multivariate.py now calls CholeskyCorrTransform(n=n); tests drop the upper parametrization. Tests: tests/distributions/test_transform.py 76 passed, with 1 pre-existing failure in test_invalid_jacobian_broadcast_raises that fails the same way on unmodified main and passes in isolation; tests/distributions/test_multivariate.py -k lkjcorr 18 passed; ruff format --check passes on all three files. Note: ruff check reports 4 pre-existing errors in multivariate.py that are also present on unmodified main. Prepared with AI assistance (Muse).

@saifmodan2006 saifmodan2006 changed the title Fix CholeskyCorrTransform with upper=True returning a lower-triangular factor Remove upper option from CholeskyCorrTransform Nov 20, 2026
@codecov

codecov Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.24%. Comparing base (bc3904b) to head (d335d8a).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #8653      +/-   ##
==========================================
+ Coverage   92.21%   92.24%   +0.03%     
==========================================
  Files         129      130       +1     
  Lines       21567    21743     +176     
==========================================
+ Hits        19887    20056     +169     
- Misses       1680     1687       +7     
Files with missing lines Coverage Δ
pymc/distributions/multivariate.py 95.58% <100.00%> (ø)
pymc/distributions/transforms.py 100.00% <100.00%> (ø)

... and 6 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ricardoV94
ricardoV94 merged commit 4e645b8 into pymc-devs:main Nov 20, 2026
42 checks passed
@welcome

welcome Bot commented Nov 20, 2026

Copy link
Copy Markdown

Congratulations Banner]
Congrats on merging your first pull request! 🎉 We here at PyMC are proud of you! 💖 Thank you so much for your contribution 🎁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: CholeskyCorr(upper=True) returns a lower-triangular factor

2 participants